package com.bjpowernode.servlets;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class RegisterServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		// 解决POST提交时的中文乱码问题，其无法解决GET提交时的中文乱码
		// setCharacterEncoding()方法设置了请求正文中的字符编码
		request.setCharacterEncoding("UTF-8");
		
		String name = request.getParameter("name");
		String age = request.getParameter("age");
		
		System.out.println("name = " + name);
		System.out.println("age = " + age);
		/*
		PrintWriter out = response.getWriter();
		out.println("name = " + name);
		out.println("age = " + age);
		*/
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request, response);
	}

}
